clear all
cd "C:\Users\ot3\Documents\CRFertility\CensusMicrodata"

set more off

clear
quietly infix               ///
  int     year       1-4    ///
  byte    datanum    5-6    ///
  double  serial     7-14   ///
  float   hhwt       15-24  ///
  byte    statefip   25-26  ///
  byte    gq         27-27  ///
  int     pernum     28-31  ///
  float   perwt      32-41  ///
  byte    sex        42-42  ///
  int     age        43-45  ///
  byte    marst      46-46  ///
  int     birthyr    47-50  ///
  byte    chborn     51-52  ///
  byte    race       53-53  ///
  int     raced      54-56  ///
  byte    hispan     57-57  ///
  int     hispand    58-60  ///
  int     bpl        61-63  ///
  long    bpld       64-68  ///
  byte    educ       69-70  ///
  int     educd      71-73  ///
  long    inctot     74-80  ///
  long    ftotinc    81-87  ///
  int     poverty    88-90  ///
  byte    migrate5   91-91  ///
  byte    migrate5d  92-93  ///
  int     migplac5   94-96  ///
  using `"usa_00026.dat"'

replace hhwt      = hhwt      / 100
replace perwt     = perwt     / 100

format serial    %8.0f
format hhwt      %10.2f
format perwt     %10.2f

keep if age>=44 & age<=70

keep if hispan==0 & race<=2
recode race (1=0)(2=1), gen(black)

drop if inlist(statefip, 2,15) //live in AK & HI
drop if inlist(bpl, 2,15) //born in AK & HI
recode bpl (1 5 12 13  22 28 37 45 47 48 51 = 1)(nonmiss = 0), gen(bornsouth)
recode statefip (1 5 12 13  22 28 37 45 47 48 51 = 1)(nonmiss = 0), gen(livesouth)

rename birthyr cohort
keep if cohort>=1920

drop if chborn==0
replace chborn=chborn-1

cd "C:\Users\ot3\Documents\CRFertility"
save census_compfer_clean, replace













